package com.eveinfo.api.character.sheet;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

import com.eveinfo.api.ApiResponse;


public class ApiSheet extends ApiResponse {

	private static final long serialVersionUID = -2205249409509548576L;

	private int characterID;
	private String name;
	private String race;
	private String bloodLine;
	private String gender;
	private String corporationName;
	private int corporationID;
	private double balance;
	private final Set<ApiAttributeEnhancer> attributeEnhancers;
	private int intelligence;
	private int memory;
	private int charisma;
	private int perception;
	private int willpower;
	private final HashMap<Integer, ApiKnownSkill> skills;
	private final HashSet<Integer> certificates;

	private String apiKey;
	private int userId;

	public ApiSheet() {
		skills = new HashMap<Integer, ApiKnownSkill>();
		certificates = new HashSet<Integer>();
		attributeEnhancers = new HashSet<ApiAttributeEnhancer>(5);
	}

	public int getCharacterID() {
		return characterID;
	}

	public void setCharacterID(int characterID) {
		this.characterID = characterID;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getRace() {
		return race;
	}

	public void setRace(String race) {
		this.race = race;
	}

	public String getBloodLine() {
		return bloodLine;
	}

	public void setBloodLine(String bloodLine) {
		this.bloodLine = bloodLine;
	}

	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	public String getCorporationName() {
		return corporationName;
	}

	public void setCorporationName(String corporationName) {
		this.corporationName = corporationName;
	}

	public int getCorporationID() {
		return corporationID;
	}

	public void setCorporationID(int corporationID) {
		this.corporationID = corporationID;
	}

	public double getBalance() {
		return balance;
	}

	public void setBalance(double balance) {
		this.balance = balance;
	}

	public void addAttributeEnhancer(ApiAttributeEnhancer attributeEnhancer) {
		attributeEnhancers.add(attributeEnhancer);
	}

	public Set<ApiAttributeEnhancer> getAttributeEnhancers() {
		return attributeEnhancers;
	}

	public int getIntelligence() {
		return intelligence;
	}

	public void setIntelligence(int intelligence) {
		this.intelligence = intelligence;
	}

	public int getMemory() {
		return memory;
	}

	public void setMemory(int memory) {
		this.memory = memory;
	}

	public int getCharisma() {
		return charisma;
	}

	public void setCharisma(int charisma) {
		this.charisma = charisma;
	}

	public int getPerception() {
		return perception;
	}

	public void setPerception(int perception) {
		this.perception = perception;
	}

	public int getWillpower() {
		return willpower;
	}

	public void setWillpower(int willpower) {
		this.willpower = willpower;
	}

	public void addSkill(ApiKnownSkill skill) {
		skills.put(skill.getTypeID(), skill);
	}

	public HashMap<Integer, ApiKnownSkill> getSkills() {
		return skills;
	}

	public boolean contains(int skillId) {
		return skills.containsKey(skillId);
	}

	public int getSkillLevel(int typeID) {
		ApiKnownSkill skill = skills.get(typeID);
		if (skill == null)
			return -1;
		return skill.getLevel();
	}
	
	public ApiKnownSkill getSkill(int typeID) {
		return skills.get(typeID);
	}

	public void setApiKey(String apiKey) {
		this.apiKey = apiKey;
	}

	public String getApiKey() {
		return apiKey;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public int getUserId() {
		return userId;
	}

	public boolean addCertificate(int number) {
		return certificates.add(number);
	}

	public Set<Integer> getCertificates() {
		return certificates;
	}

	public boolean haveCertificate(int id) {
		return certificates.contains(id);
	}
	
	public int getAttributeBonus(Class<? extends ApiAttributeEnhancer> clazz){
		for(ApiAttributeEnhancer attributeEnhancer : attributeEnhancers){
			Class<? extends ApiAttributeEnhancer> class1 = attributeEnhancer.getClass();
			if(class1.getName().equals(clazz.getName())){
				return attributeEnhancer.getAugmentatorValue();
			}
		}
		return 0;
	}
	
	public String getNameBonus(Class<? extends ApiAttributeEnhancer> clazz){
		for(ApiAttributeEnhancer attributeEnhancer : attributeEnhancers){
			Class<? extends ApiAttributeEnhancer> class1 = attributeEnhancer.getClass();
			if(class1.getName().equals(clazz.getName())){
				return attributeEnhancer.getAugmentatorName();
			}
		}
		return "No implant";
	}
}
